print("==========写文件==========")
t = open('zifu.txt', 'a')
num = t.write('你好吗，我很好\n')
print(num)
t.close()

print("==========读文件==========")
f = open('zifu.txt', 'r')
# s = f.read()
# s = f.readline()  # 读取单独的一行
# s = f.readlines()  # 将返回该文件中包含的所有行
# print(s)
for line in f:
    print(line, end='')
f.close()

# 读取数据，生成SQL
t = open(f'e:/user_info_sql.txt', 'a')
t.write('INSERT INTO `t_user` (`username`, `password`, `tel`, `address`) VALUES  \n')
for i in range(1, 10):
    t.write(f"('名字{i}', '123456', '15615615656', '2022-01-01'),\n")
t.write(';')
t.close()
